package com.yf.dao;

import com.yf.bean.CommentBean;
import com.yf.bean.CommentOpBean;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class CommentDao extends BaseDao {
    public int addComment(CommentBean bean) {
        return sessionTemplate.insert(getStatement("addComment"), bean);
    }

    public List<CommentBean> getCommentByPid(Map<String, Object> params) {
        return sessionTemplate.selectList(getStatement("getCommentByPid"), params);
    }

    public List<CommentBean> getCommentByCid(Map<String, Object> params) {
        return sessionTemplate.selectList(getStatement("getCommentByCid"), params);
    }

    public int updateLike(Map<String, Object> params) {
        return sessionTemplate.update(getStatement("updateLike"), params);
    }

    public int updateDislike(Map<String, Object> params) {
        return sessionTemplate.update(getStatement("updateDislike"), params);
    }

    public int deleteComment(Integer id) {
        return sessionTemplate.update(getStatement("deleteComment"), id);
    }

    public int checkCommentOwner(Map<String, Object> params) {
        return sessionTemplate.selectOne(getStatement("checkCommentOwner"), params);
    }

    public CommentBean getCommentById(Integer id) {
        return sessionTemplate.selectOne(getStatement("getCommentById"), id);
    }

    public int getUserUnread(Integer uid) {
        return sessionTemplate.selectOne(getStatement("getUserUnread"), uid);
    }

    public int addCommentOp(Map<String, Object> bean) {
        return sessionTemplate.insert(getStatement("addCommentOp"), bean);
    }

    public Short queryCommentOp(Map<String, Object> params) {
        return sessionTemplate.selectOne(getStatement("queryCommentOp"), params);
    }

    public int updateCommentOp(Map<String, Object> params) {
        return sessionTemplate.update(getStatement("updateCommentOp"), params);
    }

}
